﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Koala.Pro.CodeGenerator.UI.DatabaseModel.Schema
{
    public class KeyInfo
    {
        private NameElement tableName;

        private NameElement columnName;

        public NameElement TableName
        {
            get
            {
                return tableName;
            }
            set
            {
                tableName = value;
            }
        }

        public NameElement ColumnName
        {
            get
            {
                return columnName;
            }
            set
            {
                columnName = value;
            }
        }

        public string WholeName => $"{tableName.ToString()}.{columnName.ToString()}";

        public KeyInfo()
        {
        }

        public KeyInfo(string tableName, string columnName)
        {
            this.tableName = new NameElement(tableName);
            this.columnName = new NameElement(columnName);
        }

        public KeyInfo(string tableName, string tableAlias, string columnName, string columnAlias)
        {
            this.tableName = new NameElement(tableName, tableAlias);
            this.columnName = new NameElement(columnName, columnAlias);
        }

        public override string ToString()
        {
            return $"{tableName.ToString()}({columnName.ToString()})";
        }
    }

}
